{% if hookable_metadata.context.resources.data.nbResults > 0 %}

    {% set route = app.request.attributes.get('_route') %}
    {% set route_parameters = app.request.attributes.all('_route_params')|merge(app.request.query.all) %}

    {% set criteria = app.request.query.all('criteria') %}

    {% if app.request.query.all()['sorting'] is not defined or app.request.query.all()['sorting'] is empty %}
        {% set current_sorting_label = 'sylius.ui.by_position'|trans|lower %}
    {% elseif app.request.query.all()['sorting'].name is defined and app.request.query.all()['sorting'].name == 'asc'%}
        {% set current_sorting_label = 'sylius.ui.from_a_to_z'|trans|lower %}
    {% elseif app.request.query.all()['sorting'].name is defined and app.request.query.all()['sorting'].name == 'desc'%}
        {% set current_sorting_label = 'sylius.ui.from_z_to_a'|trans|lower %}
    {% elseif app.request.query.all()['sorting'].createdAt is defined and app.request.query.all()['sorting'].createdAt == 'desc'%}
        {% set current_sorting_label = 'sylius.ui.newest_first'|trans|lower %}
    {% elseif app.request.query.all()['sorting'].createdAt is defined and app.request.query.all()['sorting'].createdAt == 'asc'%}
        {% set current_sorting_label = 'sylius.ui.oldest_first'|trans|lower %}
    {% elseif app.request.query.all()['sorting'].price is defined and app.request.query.all()['sorting'].price == 'asc'%}
        {% set current_sorting_label = 'sylius.ui.cheapest_first'|trans|lower %}
    {% elseif app.request.query.all()['sorting'].price is defined and app.request.query.all()['sorting'].price == 'desc' %}
        {% set current_sorting_label = 'sylius.ui.most_expensive_first'|trans|lower %}
    {% endif %}

    <div class="dropdown">
        {% hook 'sorting' with { route, route_parameters, current_sorting_label, criteria } %}
    </div>
{% endif %}
